﻿using PLC.Domain.Dto;
using PLC.Domain.Entity;
using PLC.Domain.Enum;
using PLC.Domain.Models;

namespace PLC.Domain.ScheduledTasks.Strategy.Trigger;

public abstract class BaseTrigger
{
    /// <summary>
    /// 需要触发的事件的标识
    /// </summary>
    public abstract EnumTrigger EnumTrigger { get; protected set; }
    /// <summary>
    /// 具体要出发的事件
    /// </summary>
    /// <param name="trigger"></param>
    /// <param name="plcReadModel"></param>
    /// <returns></returns>
    public abstract int TriggerEvent(PLCConfig plcConfig,DtoDataConfig trigger, PLCReadModel plcReadModel);

    /// <summary>
    /// 校验 条码数据的个数 如果是0 那么好抛出异常
    /// </summary>
    /// <param name="barcodeDatas"></param>
    protected void CheckBarcodeDataCount(List<BarcodeData> barcodeDatas)
    {
        if (barcodeDatas.Count == 0)
        {
            throw new Exception("没有条码可以判断");
        }
    }
}